

import requests
url = 'http://www.baidu.com/s?wd=ip'
headers ={
        'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36'
    }

response = requests.get(url=url,headers=headers,proxies={"http":'47.106.105.236'})
response.encoding = 'utf-8'
page_text = response.text
with open('ip.html','w',encoding='utf-8') as fp:
    fp.write(page_text)

    #反爬机制：封iIP
    #反反爬策略：使用代理进行请求发送